package com.cat.dataStructure;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/powx-n/
 * @create 2025/10/2 10:05
 * @since JDK17
 */

public class Solution90 {
    public double myPow(double x, int n) {
        long m = n;
        double ans = 1;
        if (n < 0) {
            m = -m;
            x = 1 / x;
        }
        while (m != 0) {
            if ((m & 1) != 0) {
                ans *= x;
            }
            x *= x;
            m >>= 1;
        }
        return ans;
    }
}
